package stu.day19_day24.day21;

public class LeetCode69 {
    public int mySqrt(int x) {
        long left = 0;
        long right = x+1;
        long mid;
        while (left<right){
            mid = (left+right)/2;
            long sque = mid*mid;
            if(sque==x){
                return (int)mid;
            }

            if(sque>=x){
                right = mid;
            }else {
                left = mid+1;
            }
        }
        return (int)left-1;



    }
}
